<template>
    <div class="container">
        <!-- 商家管理页面的顶部数据区域 -->
        <div class="info">
            <div class="total business-total">
                <el-icon :size="20">
                    <ElemeFilled />
                </el-icon>
                <div>
                    <p>总商家数</p>
                    <span>3</span>
                </div>
            </div>
            <div class="total active-total">
                <el-icon :size="20">
                    <Select />
                </el-icon>
                <div>
                    <p>活跃商家</p>
                    <span>3</span>
                </div>

            </div>
            <div class="total apply-total">
                <el-icon :size="20">
                    <Timer />
                </el-icon>
                <div>
                    <p>待审核商家</p>
                    <span>3</span>
                </div>
            </div>
        </div>
        <!-- 商家管理的表格区域 -->
        <el-card>
            <template #header>
                <div class="table-header">
                    <h3>商家管理</h3>
                    <div class="search">
                        <el-input placeholder="搜素商家的名称或ID"></el-input>
                        <el-button type="primary">搜索</el-button>
                    </div>
                </div>
            </template>
            <el-table :data="tableData" border>
                <el-table-column type="index" lable="序号"></el-table-column>
                <el-table-column label="商家名称" prop="businessName"></el-table-column>
                <el-table-column label="商家地址" prop="businessAddress"></el-table-column>
                <el-table-column label="商家介绍" prop="businessExplain"></el-table-column>
                <el-table-column label="起送费" prop="starPrice"></el-table-column>
                <el-table-column label="配送费" prop="deliveryPrice"></el-table-column>
                <el-table-column label="操作">
                    <template #default="scope">
                        <el-button type="primary">编辑</el-button>
                        <el-button type="danger">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script setup>
import { businessList } from "@/api/business"
import { reactive, ref } from "vue";

// 加载表格中的数据
// let tableData = ref([])
let tableData = reactive([])
// 获取商家列表数据
businessList().then(resp => { 
    console.log(resp);
    tableData.push(...resp.data)
})

</script>

<style lang="less" scoped>
.info{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    .total{
        width: 30%;
        padding: 20px;
        box-shadow: 0px 1px 4px rgba(0,0,0,0.08);
        display: flex;
        justify-content: start;
        align-items: center;
        .el-icon{
            margin-right: 20px;
        }
    }
}
.table-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .search{
        display: flex;
    }
}
</style>